//
//  Mybutton.m
//  SmileRead
//
//  Created by dllo on 15/8/22.
//  Copyright (c) 2015年 JIZ. All rights reserved.
//

#import "Mybutton.h"
#import "JokesModel.h"
#import "Path.h"
#import "VoiceModel.h"

@interface Mybutton ()

@property (nonatomic, retain) UILabel *lableOfName;

@property (nonatomic, retain) UILabel *lableOftime;

@end

@implementation Mybutton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.personImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.height, self.frame.size.height)];
        //self.personImage.backgroundColor = [UIColor cyanColor];
        self.personImage.layer.cornerRadius = self.frame.size.height / 2;
        self.personImage.layer.masksToBounds = YES;
#warning 实验
        
        self.personImage.image = [UIImage imageNamed:@"register.png"];
        
        [self addSubview:self.personImage];
        [_personImage release];
        
        self.lableOfName = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.height + 10 * widthFit, 0, self.frame.size.width - self.frame.size.height - 10 * widthFit, self.frame.size.height / 2 * heightFit)];
        //self.lableOfName.backgroundColor = [UIColor grayColor];
        [self addSubview:self.lableOfName];
        [_lableOfName release];
        self.lableOfName.font = [UIFont systemFontOfSize:20];
        //self.lableOfName.text = @"Sponge";
        
        self.lableOftime = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.height + 10 * widthFit, self.frame.size.height / 2 , self.frame.size.width - self.frame.size.height - 10 * widthFit, self.frame.size.height / 2 )];
        //self.lableOftime.backgroundColor = [UIColor greenColor];
        [self addSubview:self.lableOftime];
        [_lableOftime release];
        
        //self.lableOftime.text = @"2015.8.21";
    }
    return self;
}

- (void)setModel:(JokesModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
        
        [Path pathWithImageView:self.personImage URLString:_model.profile_image];
        self.lableOfName.text = model.name;
        self.lableOftime.text = model.passtime;
    }
}



- (void)dealloc
{
    [_lableOfName release];
    [_lableOftime release];
    [_personImage release];
    [_model release];
    [super dealloc];
}

@end
